package com.hsc.yalebao.tabMine;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.handmark.pulltorefresh.library.ILoadingLayout;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.hsc.yalebao.adapter.MessageListViewAdapter;
import com.hsc.yalebao.base.ActivityStack;
import com.hsc.yalebao.base.BaseActivity;
import com.hsc.yalebao.base.CustomApplication;
import com.hsc.yalebao.base.MainActivity;
import com.hsc.yalebao.http.AppConstants;
import com.hsc.yalebao.http.RequestNet;
import com.hsc.yalebao.model.MessageTitleBean;
import com.hsc.yalebao.model.MessageTitleBean.ResultBean;
import com.hsc.yalebao.model.UserBaseBean;
import com.hsc.yalebao.tools.NoDoubleClickUtils;
import com.hsc.yalebao.tools.UiUtil;
import com.hsc.yalebao.weight.LogUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import java.util.ArrayList;
import java.util.HashMap;
import okhttp3.Call;

public class MyMessageActivity extends BaseActivity
{
  private String TAG = "MyMessageActivity";
  MessageListViewAdapter adapter;
  private View contentView;
  private Context context;
  private View emptyView;
  private boolean isEnd = false;
  private ImageView iv_title_right;
  private PullToRefreshListView listview;
  int memberid;
  private ArrayList<MessageTitleBean.ResultBean> messageList;
  View.OnClickListener onClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      switch (paramAnonymousView.getId())
      {
      case 2131099704:
      default:
        return;
      case 2131099699:
      }
      CustomApplication.app.finishActivity(MyMessageActivity.this);
    }
  };
  private int page = 1;
  private TextView tv_tishi;

  private void getMessageTitle(final boolean paramBoolean)
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("memberid", this.memberid);
    localHashMap.put("isread", "-1");
    localHashMap.put("page", this.page);
    localHashMap.put("pagesize", "10");
    localHashMap.put("type", "2");
    LogUtils.e(this.TAG, "memberid:" + this.memberid);
    LogUtils.d(this.TAG, "URL:" + AppConstants.URL_USER_GETMESSAGELIST);
    showLoadingDialog();
    RequestNet.get(this.context, AppConstants.URL_USER_GETMESSAGELIST, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        MyMessageActivity.this.dismissLoadingDialog();
        MyMessageActivity.this.listview.onRefreshComplete();
        LogUtils.e(MyMessageActivity.this.TAG, "获取失败,getMessageTitle-result:" + paramAnonymousException);
        MyMessageActivity.this.listview.setEmptyView(MyMessageActivity.this.emptyView);
        MyMessageActivity.this.tv_tishi.setText("获取失败");
      }

      public void onResponse(String paramAnonymousString)
      {
        MyMessageActivity.this.dismissLoadingDialog();
        MyMessageActivity.this.listview.onRefreshComplete();
        if ((paramAnonymousString == null) || ("".equals(paramAnonymousString)))
        {
          LogUtils.e(MyMessageActivity.this.TAG, "result:" + paramAnonymousString);
          MyMessageActivity.this.tv_tishi.setText("获取失败");
        }
        MessageTitleBean localMessageTitleBean;
        do
        {
          return;
          Gson localGson = new Gson();
          try
          {
            localMessageTitleBean = (MessageTitleBean)localGson.fromJson(paramAnonymousString, MessageTitleBean.class);
            if (localMessageTitleBean == null)
            {
              LogUtils.e(MyMessageActivity.this.TAG, "getMessageTitle == null，获取失败");
              MyMessageActivity.this.tv_tishi.setText("获取失败");
              return;
            }
          }
          catch (Exception localException)
          {
            while (true)
            {
              localException.printStackTrace();
              localMessageTitleBean = null;
            }
            LogUtils.e(MyMessageActivity.this.TAG, "获取flag=" + localMessageTitleBean.flag);
            if (localMessageTitleBean.flag == 0)
            {
              MyMessageActivity.this.listview.setEmptyView(MyMessageActivity.this.emptyView);
              MyMessageActivity.this.tv_tishi.setText("暂无消息");
              return;
            }
            if (localMessageTitleBean.flag == -2)
            {
              MyMessageActivity.this.showDownWireDialog();
              return;
            }
            if (localMessageTitleBean.flag == -3)
            {
              MyMessageActivity.this.ShowFengjinDialog();
              return;
            }
            if (localMessageTitleBean.flag == -4)
            {
              MyMessageActivity.activityStack.backToMain(MainActivity.class, MyMessageActivity.this.context);
              return;
            }
          }
        }
        while (localMessageTitleBean.flag != 1);
        if (localMessageTitleBean.result == null)
        {
          LogUtils.e(MyMessageActivity.this.TAG, "issueListBean.result == null");
          return;
        }
        if (paramBoolean)
          if ((MyMessageActivity.this.messageList != null) && (localMessageTitleBean.result.size() > 0))
          {
            MyMessageActivity.this.messageList.addAll(localMessageTitleBean.result);
            if (MyMessageActivity.this.messageList.size() >= 10)
              break label418;
            MyMessageActivity.this.isEnd = true;
          }
        for (int i = 0; ; i++)
        {
          if (i >= MyMessageActivity.this.messageList.size())
          {
            if (MyMessageActivity.this.messageList.size() != 0)
              break label493;
            MyMessageActivity.this.listview.setEmptyView(MyMessageActivity.this.emptyView);
            MyMessageActivity.this.tv_tishi.setText("暂无消息");
            return;
            label418: MyMessageActivity.this.isEnd = false;
            break;
            MyMessageActivity.this.messageList = localMessageTitleBean.result;
            break;
          }
          LogUtils.e(MyMessageActivity.this.TAG, "title" + ((MessageTitleBean.ResultBean)MyMessageActivity.this.messageList.get(i)).Title);
        }
        label493: if (MyMessageActivity.this.adapter != null)
        {
          MyMessageActivity.this.adapter.setData(MyMessageActivity.this.messageList);
          MyMessageActivity.this.adapter.notifyDataSetChanged();
          LogUtils.e(MyMessageActivity.this.TAG, "更新数据");
          return;
        }
        MyMessageActivity.this.adapter = new MessageListViewAdapter(MyMessageActivity.this.messageList, MyMessageActivity.this.context);
        MyMessageActivity.this.listview.setAdapter(MyMessageActivity.this.adapter);
        LogUtils.e(MyMessageActivity.this.TAG, "第一次设置数据");
      }
    });
  }

  private void initData()
  {
    this.messageList = new ArrayList();
    getMessageTitle(false);
  }

  private void initRefresh()
  {
    this.listview.setMode(PullToRefreshBase.Mode.BOTH);
    this.listview.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener()
    {
      public void onRefresh(PullToRefreshBase<ListView> paramAnonymousPullToRefreshBase)
      {
        String str = DateUtils.formatDateTime(MyMessageActivity.this.getApplicationContext(), System.currentTimeMillis(), 524305);
        paramAnonymousPullToRefreshBase.getLoadingLayoutProxy().setLastUpdatedLabel(str);
        if (MyMessageActivity.this.listview.isHeaderShown())
        {
          LogUtils.e(MyMessageActivity.this.TAG, "mPullRefreshListView刷新");
          MyMessageActivity.this.refeshList();
          return;
        }
        LogUtils.e(MyMessageActivity.this.TAG, "mPullRefreshListView加载");
        if (MyMessageActivity.this.isEnd)
          UiUtil.showToast(MyMessageActivity.this.context, "暂无更多数据");
        MyMessageActivity localMyMessageActivity = MyMessageActivity.this;
        localMyMessageActivity.page = (1 + localMyMessageActivity.page);
        MyMessageActivity.this.getMoreList();
      }
    });
  }

  private void initView()
  {
    this.listview = ((PullToRefreshListView)findViewById(2131099717));
    this.emptyView = LayoutInflater.from(this.context).inflate(2130903139, null);
    this.tv_tishi = ((TextView)this.emptyView.findViewById(2131100053));
    this.tv_tishi.setText("获取中...");
    setTitle(8, 0, 2130837809, "我的消息", 0, 8, 8, 0, true);
    initRefresh();
  }

  protected void getMoreList()
  {
    getMessageTitle(true);
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    this.context = this;
    this.contentView = LayoutInflater.from(this.context).inflate(2130903069, null);
    setContentView(this.contentView);
    CustomApplication.app.addActivity(this);
    initView();
    if (CustomApplication.app.userBaseBean != null)
      this.memberid = CustomApplication.app.userBaseBean.getMemberid();
    initData();
    this.listview.setOnItemClickListener(new AdapterView.OnItemClickListener()
    {
      public void onItemClick(AdapterView<?> paramAnonymousAdapterView, View paramAnonymousView, int paramAnonymousInt, long paramAnonymousLong)
      {
        try
        {
          if (NoDoubleClickUtils.isDoubleClick())
            return;
          int i = paramAnonymousInt - 1;
          Intent localIntent = new Intent(MyMessageActivity.this, DetailMessageActivity.class);
          MessageTitleBean.ResultBean localResultBean = (MessageTitleBean.ResultBean)MyMessageActivity.this.messageList.get(i);
          localIntent.putExtra("message", localResultBean);
          MyMessageActivity.this.startActivity(localIntent);
          localResultBean.IsRead = "1";
          MyMessageActivity.this.adapter.notifyDataSetChanged();
          return;
        }
        catch (Exception localException)
        {
          localException.printStackTrace();
        }
      }
    });
  }

  protected void onResume()
  {
    super.onResume();
  }

  protected void refeshList()
  {
    this.page = 1;
    getMessageTitle(false);
  }

  @SuppressLint({"NewApi"})
  public void setTitle(int paramInt1, int paramInt2, int paramInt3, String paramString, int paramInt4, int paramInt5, int paramInt6, int paramInt7, boolean paramBoolean)
  {
    View localView = findViewById(2131099716);
    if (paramBoolean)
      localView.setVisibility(0);
    while (true)
    {
      ((TextView)localView.findViewById(2131099701)).setText(paramString);
      ((TextView)localView.findViewById(2131099700)).setVisibility(paramInt1);
      ImageView localImageView = (ImageView)localView.findViewById(2131099699);
      localImageView.setVisibility(paramInt2);
      localImageView.setOnClickListener(this.onClickListener);
      localImageView.setImageResource(paramInt3);
      TextView localTextView = (TextView)localView.findViewById(2131099702);
      localTextView.setVisibility(paramInt5);
      localTextView.setOnClickListener(this.onClickListener);
      this.iv_title_right = ((ImageView)localView.findViewById(2131099704));
      this.iv_title_right.setVisibility(paramInt6);
      this.iv_title_right.setOnClickListener(this.onClickListener);
      this.iv_title_right.setImageResource(paramInt7);
      return;
      localView.setVisibility(8);
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.tabMine.MyMessageActivity
 * JD-Core Version:    0.6.2
 */